package asteroids.model.programs.parsing;

import java.util.List;

import asteroids.model.Ship;
import asteroids.model.expressions.*;
import asteroids.model.statements.*;
import asteroids.model.types.*;

public class ProgramFactoryImpl implements ProgramFactory<E, S, T>{
	
	
	public ProgramFactoryImpl() {
	}

	@Override
	public E createDoubleLiteral(int line, int column, double d) {
		return new DoubleLiteral(d);
	}

	@Override
	public E createBooleanLiteral(int line, int column, boolean b) {
		return new BooleanLiteral(b);
	}

	@Override
	public E createAnd(int line, int column, E e1, E e2) {
		return new And(e1, e2);
	}

	@Override
	public E createOr(int line, int column, E e1, E e2) {
		return new Or(e1, e2);
	}

	public E createNot(int line, int column, E e) {
		  return new Not(e);
	}
	public E createNull(int line, int column) {
		  return new NullLiteral();
	}
	public E createSelf(int line, int column) {
		  return new Self();
	}
	public E createGetX(int line, int column, E e) {
		  return new GetX(e);
	}
	public E createGetY(int line, int column, E e) {
		  return new GetY(e);
	}
	public E createGetVX(int line, int column, E e) {
		  return new GetVX(e);
	}
	public E createGetVY(int line, int column, E e) {
		  return new GetVY(e);
	}
	public E createGetRadius(int line, int column, E e) {
		  return new GetRadius(e);
	}
	public E createVariable(int line, int column, String name) {
		return new Variable(name);
	}
	public E createLessThan(int line, int column, E e1, E e2) {
		  return new LessThan(e1,e2);
	}
	public E createGreaterThan(int line, int column, E e1, E e2) {
		  return new GreaterThan(e1,e2);
	}
	public E createLessThanOrEqualTo(int line, int column, E e1, E e2) {
		  return new LessThanOrEqualTo(e1,e2);
	}
	public E createGreaterThanOrEqualTo(int line, int column, E e1, E e2) {
		  return new GreaterThanOrEqualTo(e1,e2);
	}
	public E createEquality(int line, int column, E e1, E e2) {
		  return new Equals(e1,e2);
	}
	public E createInequality(int line, int column, E e1, E e2) {
		  return new InEquals(e1,e2);
	}
	public E createAdd(int line, int column, E e1, E e2) {
		  return new Add(e1,e2);
	}
	public E createSubtraction(int line, int column, E e1, E e2) {
		  return new Subtraction(e1,e2);
	}
	public E createMul(int line, int column, E e1, E e2) {
		  return new Multiplication(e1,e2);
	}
	public E createDivision(int line, int column, E e1, E e2) {
		  return new Division(e1,e2);
	}
	public E createSqrt(int line, int column, E e) {
		  return new Sqrt(e);
	}
	public E createGetDirection(int line, int column) {
		  return new GetDirection();
	}
	public E createSin(int line, int column, E e) {
		  return new Sin(e);
	}
	public E createCos(int line, int column, E e) {
		  return new Cos(e);
	}

	@Override
	public S createEnableThruster(int line, int column) {
		Thrust thruster = new Thrust();
		return thruster;
	}

	@Override
	public S createDisableThruster(int line, int column) {
		return new ThrustOff();
	}

	@Override
	public S createFire(int line, int column) {
		return new Fire();
	}

	@Override
	public S createTurn(int line, int column, E angle) {
		Turn turn = new Turn(angle);
		return turn;		
	}

	@Override
	public S createAssignment(int line, int column, String variable, E rhs) {
		Assignment assignment = new Assignment(variable, rhs);
		return assignment;
	}

	@Override
	public S createIf(int line, int column, E condition, S then, S otherwise) {
		return new IfElse(condition, then, otherwise);
	}

	@Override
	public S createWhile(int line, int column, E condition, S body) {
		WhileLoop whileStatement = new WhileLoop(condition, body);
		return whileStatement;
	}

	@Override
	public S createForeach(int line, int column,
			asteroids.model.programs.parsing.ProgramFactory.ForeachType type,
			String variableName, S body) {
		return new ForEach(body, variableName, type);
	}

	@Override
	public S createSkip(int line, int column) {
		return new Skip();
	}

	@Override
	public S createSequence(int line, int column, List<S> statements) {
		Sequence sequence = new Sequence(statements);
		return sequence;
	}

	@Override
	public S createPrint(int line, int column, E e) {
		return new Print(e);
	}

	@Override
	public T createDoubleType() {
		DoubleType d = new DoubleType();
		return d;
	}

	@Override
	public T createBooleanType() {
		return new BooleanType();
	}

	@Override
	public T createEntityType() {
		return new Entity();
	}

}
